﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TraCuuTinRaoVat
{
    public partial class UserControlDanhMucChinh : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                LinQ_RaoVatDataContext danhsach = new LinQ_RaoVatDataContext();
                DANH_MUC_CHINH dmChinh = new DANH_MUC_CHINH();
                dmChinh.TenDanhMucChinh = txtTenDanhMuc.Text;

                if( int.Parse(dropTrangThai.SelectedValue.ToString()) == 1)
                {
                    dmChinh.Deleted = true;
                }
                else{
                    dmChinh.Deleted = false;
                }
                danhsach.DANH_MUC_CHINHs.InsertOnSubmit(dmChinh);
                danhsach.SubmitChanges();
                lblResultChinh.Text = "Thêm danh mục chính thành công";
            }
            catch (Exception ex)
            {
                lblResultChinh.Text = "Kiểm tra lại dữ liệu nhập";
            }
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
            txtTenDanhMuc.Text = "";
        }
    }
}